{include file="header.html"}
{include file="title.html"}

<script type="text/javascript">
//注册表单验证
    $(function() {
        var vali=$('#register_form').validate({
            errorPlacement: function(error, element) {
                var error_td = element.parent('td');
                error_td.find('.field_notice').hide();
                error_td.append(error);
            },
            success: function(label) {
                label.addClass('validate_right').text('OK!');
            },
            onkeyup: false,
            rules: {
                user_name: {
                    required: true,
                    byteRange: [3, 15, '{$charset}'],
                    remote: {
                        url: 'index.php?app=member&act=check_user&ajax=1',
                        type: 'get',
                        data: {
                            user_name: function() {
                                return $('#user_name').val();
                            }
                        },
                        beforeSend: function() {
                            var _checking = $('#checking_user');
                            _checking.prev('.field_notice').hide();
                            _checking.next('label').hide();
                            $(_checking).show();
                        },
                        complete: function() {
                            $('#checking_user').hide();
                        }
                    }
                },
                phone_mob: {
                    required: true,
                    number: true,
                    byteRange: [11, 11, '{$charset}'],
                    remote: {
                        url: 'index.php?app=member&act=check_mobile&type=register',
                        type: 'get',
                        data: {
                            phone_mob: function() {
                                return $('#phone_mob').val();
                            }
                        },
                        beforeSend: function() {
                            var _checking = $('#checking_mobile');
                            _checking.prev('.field_notice').hide();
                            _checking.next('label').hide();
                            $(_checking).show();

                        },
                        complete: function() {

                            $('#checking_mobile').hide();
                        }
                    }
                },
                confirm_code: {
                    required: true,
                    number: true,
                    byteRange: [6, 6, '{$charset}'],
                    remote: {
                        url: 'index.php?app=member&act=cmc&ajax=1',
                        type: 'get',
                        data: {
                            confirm_code: function() {
                                return $('#confirm_code').val();
                            }
                        },
                        beforeSend: function() {
                            var _checking = $('#checking_code');
                            _checking.next('label').hide();
                            $(_checking).show();

                        },
                        complete: function() {
                            $('#checking_code').hide();
                        }
                    }
                },
                password: {
                    required: true,
                    minlength: 6
                },
                password_confirm: {
                    required: true,
                    equalTo: '#password'
                },
                email: {
                    required: true,
                    email: true,
                    remote: {
                        url: 'index.php?app=member&act=check_email&ajax=1',
                        type: 'get',
                        data: {
                            email: function() {
                                return $('#email').val();
                            }
                        },
                        beforeSend: function() {
                            var _checking = $('#checking_user');
                            _checking.prev('.field_notice').hide();
                            _checking.next('label').hide();
                            $(_checking).show();
                        },
                        complete: function() {
                            $('#checking_user').hide();
                        }
                    }
                },
                captcha: {
                    required: true,
                    remote: {
                        url: 'index.php?app=captcha&act=check_captcha',
                        type: 'get',
                        data: {
                            captcha: function() {
                                return $('#captcha1').val();
                            }
                        }
                    }
                },
                agree: {
                    required: true
                }
            },
            messages: {
                user_name: {
                    required: '{$lang.user_name_required}',
                    byteRange: '{$lang.user_name_limit}',
                    remote: '{$lang.user_already_taken}'
                },
                phone_mob: {
                    required: '{$lang.phone_mob_required}',
                    number: '{$lang.phone_mob_number}',
                    byteRange: '{$lang.phone_mob_limit}',
                    remote: '{$lang.mobile_already_exsit}'
                },
                confirm_code: {
                    required: '{$lang.mobile_code_required}',
                    number: '{$lang.mobile_code_must_be_number}',
                    byteRange: '{$lang.mobile_code_limit}',
                    remote: '{$lang.mobile_code_error}'
                },
                password: {
                    required: '{$lang.password_required}',
                    minlength: '{$lang.password_length_limit}'
                },
                password_confirm: {
                    required: '{$lang.password_confirm_please}',
                    equalTo: '{$lang.password_inconsistent}'
                },
                email: {
                    required: '{$lang.email_required}',
                    email: '{$lang.email_invalid}',
                    remote: '{$lang.email_already_taken}'
                },
                captcha: {
                    required: '{$lang.captcha_required}',
                    remote: '{$lang.captcha_error}'
                },
                agree: {
                    required: '{$lang.agree_required}'
                }
            }
        });
        
        
        

     
        var time = 60;
        var dtime = 60;
        $("#sendsms").bind('click', function() {
            if(!vali.element($("[name=phone_mob]"))){
                return;
            }
            var btn = $(this);
           
            var sendaddress = $('#phone_mob').val();
            var fhm = $("label[for='phone_mob']").text();
            if (fhm != '' && fhm != "OK!") {
                alert(lang.pls_enter_right_phone);
                return;
            }
             btn.attr("disabled","true");
            $.getJSON('index.php?app=member&act=send_code&type=register', {mobile: sendaddress}, function(result)
            {
                if (result.done == true) {
                    var hander = setInterval(function() {
                        if (time <= 0) {
                            canSend = true;
                            clearInterval(hander);
                            btn.val(lang.resend_msg);
                            btn.removeAttr("disabled");
                            time = dtime;
                        } else {
                            canSend = false;
                            btn.attr({
                                "disabled": "disabled"
                            });
                            btn.val(time + lang.after_minut_send);
                            time--;
                        }
                    },
                            1000);
                    alert(lang.msg_has_send + sendaddress + lang.pls_check_receive);
                    btn.removeAttr("disabled");
                } else {
                    alert(result.msg);
                    btn.removeAttr("disabled");
                }
            });
        });
    });
</script>


<!-----登录--------->
<div class="login_panel" >
    <form class="login_box" id="register_form" method="post">
        <table  width="100%">
            <tr>
                <td> <input placeholder="{$lang.user_name}" type="text" name="user_name" id="user_name" class="text">
                    <label class="field_notice"></label></td>
            </tr>
            <tr>  
                <td> <input placeholder="{$lang.Secret_code}"  id="password" name="password" type="password"  class="text">  
                    <label class="field_notice"></label></td>
            </tr>
            <tr> 
                <td>  
                    <input placeholder="{$lang.confirm_password}"   name="password_confirm" type="password"  class="text">  
                    <label class="field_notice"></label>
                </td>
            </tr>
            <!--{if $msg_enabled}-->
            <tr> 
                <td>  
                    <input placeholder="{$lang.phone_mob}" id="phone_mob"  name="phone_mob" type="text"  class="text">  
                    <label class="field_notice"></label>
                </td>
            </tr>
            <tr> 
                <td>  
                    <input type="button" id="sendsms" value="{$lang.send_code}"/>
                </td>
            </tr>
            <tr> 
                <td>  
                    <input placeholder="{$lang.confirm_code}" id="confirm_code"  name="confirm_code" type="text"  class="text">  
                    <label class="field_notice"></label>
                </td>
            </tr>
            <!--{/if}-->
            <tr> 
                <td>  
                    <input placeholder="{$lang.email}" id="email"  name="email" type="text"  class="text">  
                    <label class="field_notice"></label>
                </td>
            </tr>
            <!--{if $captcha}-->
            <tr>
                <td class="relative"><input type="text" name="captcha" class="text" id="captcha1" placeholder="{$lang.captcha_desc}" />
                    <a href="javascript:change_captcha($('#captcha'));" class="renewedly"><img id="captcha" src="index.php?app=captcha&amp;{$random_number}" /></a></td>
            </tr>
            <!--{/if}-->

            <tr>
                <td>
                    <input  value="{$lang.register_now}"  type="submit" class="red_btn">
                </td>
            </tr>
        </table>
        <input type="hidden" name="ret_url" value="{$ret_url}" />
        <p><a href="{url app=member&act=login&ret_url=$ret_url}" >{$lang.logging}</a><a href="index.php?app=find_password&act=mobile" class="fr">{$lang.find_back}</a></p>
        <input type="hidden"  checked name="agree" value="1" value="1" > 
    </form>
</div>


{include file="footer.html"}